const BASE_URL = 'http://172.18.8.73:8000'  //公司内部
// const BASE_URL = 'http://119.147.81.103:25128'  
class http {
    static request(url, params = {}, method = "POST", contentType = "application/x-www-form-urlencoded") {
        return new Promise((resolve, reject) => {
            uni.request({
                url: BASE_URL + url, //仅为示例，并非真实接口地址。
                data: params,
                header: {
                    'Content-Type': contentType,
					 token: uni.getStorageSync("token")	
                },
                method,
                success: (res) => {
                    resolve(res.data);
                },
				fail: function(err) {
				            console.log(err)
				            uni.showToast({
				                title: '服务器出现问题，请稍后再试',
				                icon: 'none',
				         })
				  }
            });
        })
    }
	
	static upload (url, path) {
	    return new Promise((resolve, reject) => {
			uni.uploadFile({
						url: BASE_URL + url, 
						filePath: path,
						name: 'files',
						fileType: 'image',
						header:{
						   token: uni.getStorageSync("token")	
						},
						success: (res) => {
							resolve(res.data);
						}
					});
			})
	}
}

export default http
